home *** CD-ROM | disk | FTP | other *** search
/ PC World Komputer 2010 April / PCWorld0410.iso / pluginy Firefox / 1951 / 1951.xpi / chrome / fission.jar / content / fission / options.js < prev    next >
Text File  |  2009-04-26  |  2KB  |  92 lines

  1. const gDefaultColor = "#B6BDD2";
  2. const gURLBar_value = "http://www.example.net/";
  3. let gAnimation;
  4.  
  5. function initDialog()
  6. {
  7.     var flip = true;
  8.     gAnimation = setInterval(function(aProgressBar) {
  9.         if ((flip = !flip))
  10.         {
  11.             aProgressBar.value = 0;
  12.             aProgressBar.value = 33;
  13.         }
  14.         else
  15.         {
  16.             aProgressBar.value = 90;
  17.         }
  18.     }, 2000, _("statusbar-icon"));
  19. }
  20.  
  21. function uninitDialog()
  22. {
  23.     clearInterval(gAnimation);
  24. }
  25.  
  26. function writeColor()
  27. {
  28.     let image = _("color-image").value.replace(/^\s+|\s+$/g, "");
  29.     let color = _("color-plain").color;
  30.     
  31.     return (image || color != gDefaultColor) ? (image ? "url(" + image + ") " : "") + color : "";
  32. }
  33.  
  34. function readColorPlain()
  35. {
  36.     document.getAnonymousElementByAttribute(_("statusbar-icon"), "class", "progress-bar").style.background = _("extensions.fission.color").value.replace(/^(url\(.+\)) #[0-9A-F]{6}$/, "$1 repeat-x left center transparent");
  37.     
  38.     return /(#[0-9A-F]{6})$/i.test(_("extensions.fission.color").value) ? RegExp.$1 : gDefaultColor;
  39. }
  40.  
  41. function readColorImage()
  42. {
  43.     return /^url\((.+)\)/.test(_("extensions.fission.color").value) ? RegExp.$1 : "";
  44. }
  45.  
  46. function readIconize()
  47. {
  48.     let iconize = _("extensions.fission.iconize").value;
  49.     
  50.     let urlbar = _("urlbar");
  51.     urlbar.setAttribute("fission", iconize ? "icon" : "fusion");
  52.     urlbar.flex = iconize ? 0 : 1000;
  53.     urlbar.value = iconize ? "" : gURLBar_value;
  54.     
  55.     return iconize;
  56. }
  57.  
  58. function onFindImage()
  59. {
  60.     const nsIFilePicker = Components.interfaces.nsIFilePicker;
  61.     let filePicker = Components.classes["@mozilla.org/filepicker;1"].createInstance(nsIFilePicker);
  62.     
  63.     filePicker.init(window, null, nsIFilePicker.modeOpen);
  64.     filePicker.appendFilters(nsIFilePicker.filterImages);
  65.     
  66.     try
  67.     {
  68.         let uri = Components.classes["@mozilla.org/network/io-service;1"].getService(Components.interfaces.nsIIOService).newURI(_("color-image").value, null, null);
  69.         if (uri instanceof Components.interfaces.nsIFileURL && uri.file instanceof Components.interfaces.nsILocalFile)
  70.         {
  71.             filePicker.displayDirectory = uri.file.parent;
  72.         }
  73.     }
  74.     catch (ex) { /* no valid (file) URI, so no default directory to set */ }
  75.     
  76.     if (filePicker.show() == nsIFilePicker.returnOK)
  77.     {
  78.         _("color-image").value = filePicker.fileURL.spec;
  79.         _("FissionOptionsPane").userChangedValue(_("color-image"));
  80.     }
  81. }
  82.  
  83. function onResetColor()
  84. {
  85.     _("extensions.fission.color").value = "";
  86. }
  87.  
  88. function _(aId)
  89. {
  90.     return document.getElementById(aId);
  91. }
  92.